package com.itheima.kebian;

public class Demo01 {

    public static void main(String[] args) {
        int[] arr={11,22,33,44,55};
        int sum = getSum(arr);
        System.out.println(sum);
        System.out.println(getSum(1, 2));
        System.out.println(getSum(1, 2,3));
        System.out.println(getSum(1, 2,3,4));
        getSum("嘿嘿嘿,我最帅",11,22,33,44);

    }


    public static int  getSum(int a,int b){
        return a+b;
    }
    public static int  getSum(int a,int b,int c){
        return a+b+c;
    }

    //定义一个方法 求问几个数的和
    //求数组的和
   /* public static int getSum(int[] arr){
        int sum=0;
        for (int i : arr) {
            sum+=i;
        }
        return sum;
    }*/
    public static int getSum(int... arr){
        int sum=0;
        for (int i : arr) {
            sum+=i;
        }
        return sum;
    }

    public static int getSum(String s,int... arr){
        int sum=0;
        for (int i : arr) {
            sum+=i;
        }
        System.out.println(s);
        return sum;
    }
}
